package net.hn.hnms.biz.performance.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.performance.domain.PerformanceMetrics;
import net.hn.hnms.biz.performance.request.PerformanceMetricsReq;
import net.hn.hnms.biz.performance.service.PerformanceMetricsService;
import net.hn.hnms.biz.performance.vo.PerformanceMetricsVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "指标管理", tags = {"绩效指标"})
@RestController
@RequestMapping("/performanceMetrics/management")
public class PerformanceMetricsController extends BaseController {



    @Autowired
    private PerformanceMetricsService performanceMetricsService;


    @ApiOperation("指标管理分页列表")
//    @SaCheckPermission("execution:other:page")
    @GetMapping("/page")
    public R<ResponsePage<PerformanceMetricsVo>> page(PerformanceMetricsReq executionOther, PageQuery pageQuery) {
        return R.ok(performanceMetricsService.selectPageList(executionOther, pageQuery));
    }


    @ApiOperation("根据编号获取详细信息")
    @GetMapping(value = "/{performanceMetricsId}")
    public R<PerformanceMetrics> getInfo(@PathVariable Integer performanceMetricsId) {
        return R.ok(performanceMetricsService.selectPerformanceMetricsById(performanceMetricsId));
    }


    @ApiOperation("新增指标管理")
    @PostMapping("/add")
    @Log(title = "新增指标管理", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody PerformanceMetricsReq dimDrivageFace) {
        return toAjax(performanceMetricsService.insert(dimDrivageFace));
    }


    @ApiOperation("删除指标管理")
//    @SaCheckPermission("drivage:face:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除指标管理", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<Integer> idList) {
        performanceMetricsService.updateDeleteByIds(idList);
        return R.ok();
    }

    /**
     * 修改掘进工作面
     */
    @ApiOperation("修改指标管理")
//    @SaCheckPermission("drivage:face:update")
    @PutMapping("/update")
    @Log(title = "修改指标管理", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody PerformanceMetricsReq dimDrivageFace) {
        performanceMetricsService.updateById(dimDrivageFace);
        return R.ok();
    }


}
